int servo_delay = 1500; void setup() { // put your setup code here, to run once: pinMode(11,OUTPUT); pinMode(10,INPUT); pinMode(9,INPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(11,HIGH); delayMicroseconds(servo_delay); digitalWrite(11,LOW); delay(18); if (digitalRead(10) == HIGH && servo_delay<2000) { servo_delay = servo_delay +5; } if (digitalRead(9) == HIGH && servo_delay>1000) { servo_delay = servo_delay -5; } }